package com.amumu.drama.portal.modules.game.controller;

import com.amumu.drama.common.base.api.CommonPage;
import com.amumu.drama.common.base.api.CommonResult;
import com.amumu.drama.common.modules.category.dto.GameQueryDto;
import com.amumu.drama.common.modules.category.service.GameService;
import com.amumu.drama.common.modules.category.vo.GamePortalVo;
import com.amumu.drama.common.modules.category.vo.GameVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 前台商品管理Controller
 * Created by macro on 2020/4/6.
 */
@Controller
@Api(tags = "游戏")
@Tag(name = "游戏", description = "前台商品管理")
@RestController
@RequestMapping("/product")
public class PmsPortalProductController {


    @Autowired
    private GameService gameService;


    @ApiOperation("微丸子-查询游戏列表")
    @RequestMapping(value = "/pageGameList", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult<CommonPage<GameVo>> pageGameList(@Validated @RequestBody GameQueryDto gameQueryDto) {
        return CommonResult.success(gameService.pageGameList(gameQueryDto));
    }


    @ApiOperation("微丸子-获取前台游戏详情")
    @RequestMapping(value = "/getGameAndSkuInfo", method = RequestMethod.GET)
    @ResponseBody
    public CommonResult<GamePortalVo> getGameAndSkuInfo(@RequestParam Long gameId) {
        return gameService.getGameAndSkuInfo(gameId);
    }

//    @ApiOperation(value = "综合搜索、筛选、排序")
//    @ApiImplicitParam(name = "sort", value = "排序字段:0->按相关度；1->按新品；2->按销量；3->价格从低到高；4->价格从高到低",
//            defaultValue = "0", allowableValues = "0,1,2,3,4", paramType = "query", dataType = "integer")
//    @RequestMapping(value = "/search", method = RequestMethod.GET)
//    @ResponseBody
//    public CommonResult<CommonPage<PmsProduct>> search(@RequestParam(required = false) String keyword,
//                                                       @RequestParam(required = false) Long brandId,
//                                                       @RequestParam(required = false) Long productCategoryId,
//                                                       @RequestParam(required = false, defaultValue = "0") Integer pageNum,
//                                                       @RequestParam(required = false, defaultValue = "5") Integer pageSize,
//                                                       @RequestParam(required = false, defaultValue = "0") Integer sort) {
//        List<PmsProduct> productList = portalProductService.search(keyword, brandId, productCategoryId, pageNum, pageSize, sort);
//        return CommonResult.success(CommonPage.restPage(productList));
//    }
//
//    @GetMapping("/list")
//    public CommonResult<List<PmsProduct>> list() {
//        return CommonResult.success(portalProductService.list());
//    }

//    @ApiOperation("以树形结构获取所有商品分类")
//    @RequestMapping(value = "/categoryTreeList", method = RequestMethod.GET)
//    @ResponseBody
//    public CommonResult<List<PmsProductCategoryNode>> categoryTreeList() {
//        List<PmsProductCategoryNode> list = portalProductService.categoryTreeList();
//        return CommonResult.success(list);
//    }

//    @ApiOperation("获取前台商品详情")
//    @RequestMapping(value = "/detail", method = RequestMethod.GET)
//    @ResponseBody
//    public CommonResult<PmsPortalProductDetail> detail(@RequestParam Long id, @RequestParam(required = false)String invitationCode) {
//        PmsPortalProductDetail productDetail = portalProductService.detail(id, invitationCode);
//        return CommonResult.success(productDetail);
//    }


//    @ApiOperation("获取前台商品分类列表")
//    @RequestMapping(value = "/listProductCategory", method = RequestMethod.GET)
//    @ResponseBody
//    public CommonResult<List<CategorySimpleDto> > listProductCategory() {
//        List<CategorySimpleDto>  categorySimpleDtoList = portalProductService.listProductCategory();
//        return CommonResult.success(categorySimpleDtoList);
//    }

}
